/**
 * 
 */
package fr.cephb.socialsnp.webapp.form;

import fr.cephb.util.MessageType;

/**
 * @author lindenb
 *
 */
public class MaxLengthValidator
	extends AbstractValidator<Integer>
	{
	public MaxLengthValidator(int maxLength)
		{
		super(maxLength);
		}
	
	/* (non-Javadoc)
	 * @see fr.cephb.socialsnp.webapp.form.Validator#validate(fr.cephb.socialsnp.webapp.form.FormParam)
	 */
	@Override
	public void validate(FormParam param)
		{
		for(String s:param.getValues())
			{
			if(s.trim().length()> getValue())
				{
				param.getErrors().add(new ErrorMessage(
						MessageType.ERROR,
						param.getLabel()+" is too large (should be lower than "+getValue()+")"
						));
				}
			}
		}

}
